package com.lz.utils;

import com.lz.enums.CodeEnum;

/**
 * 枚举工具类
 * Created by Administrator on 2018/9/3 0003.
 */
public class EnumUtil {

    public static <T extends CodeEnum> T getByCode(Integer code, Class<T> enumClass){
        for (T each : enumClass.getEnumConstants()) {
            if (code.equals(each.getCode())){
                return each;
            }
        }
        return null;
    }
}
